using System.Collections;
using UnityEngine;

public class SharingGame : MonoBehaviour
{
	public static SharingGame instance;

	private string url = "https://play.google.com/store/apps/details?id=com.SHgames.StickmanTheFlash";

	private void Awake()
	{
		instance = this;
	}

	public void Share()
	{
		StartCoroutine(IE_Share());
	}

	private IEnumerator IE_Share()
	{
		string subject = ((!(GM.instance.language == "Korean")) ? "Stickman - The Flash" : "추천작 : 스틱맨 - 더 플래시");
		yield return new WaitForEndOfFrame();
		AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
		AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
		intentObject.Call<AndroidJavaObject>("setAction", new object[1] { intentClass.GetStatic<string>("ACTION_SEND") });
		intentObject.Call<AndroidJavaObject>("setType", new object[1] { "text/plain" });
		intentObject.Call<AndroidJavaObject>("putExtra", new object[2]
		{
			intentClass.GetStatic<string>("EXTRA_SUBJECT"),
			subject
		});
		intentObject.Call<AndroidJavaObject>("putExtra", new object[2]
		{
			intentClass.GetStatic<string>("EXTRA_TEXT"),
			url
		});
		AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
		AndroidJavaObject jChooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", new object[2]
		{
			intentObject,
			(!(GM.instance.language == "Korean")) ? "Share Via" : "이 게임 공유하기"
		});
		currentActivity.Call("startActivity", jChooser);
	}

	public void OpenTheGoogleMarket()
	{
		Application.OpenURL("market://details?id=com.SHgames.StickmanTheFlash");
	}
}
